import {
  getPersonInfoApi
} from "../../services/filing/filing"
import {
  GETSTORAGE
} from "../../services/storage/storage"
import {
  pushMessage
} from "../../services/_utils/api"
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userName: ''
  },
  // 获取用户个人信息
  getUserInfo() {
    const userId = GETSTORAGE('userId')
    getPersonInfoApi({
      userId: userId
    }).then(res => {
      console.log(res);
      this.setData({
        userName: res.data.data.nickName
      })
    })
  },

  goHealthManagement() {
    const msg = 'refresh'
    wx.navigateTo({
      url: `/pages/filing/health-management/healt-hmanagement?msg=${msg}`,
    })
  },
  goFamilyManage() {
    wx.navigateTo({
      url: `/pages/filing/invite-the-family/invite-the-family?inviteJoin=inviteJoin`,
    })
  },

  goLocation() {
    wx.navigateTo({
      url: '/pageOrder/location/location/location',
    })
  },
  goOrder() {
    wx.navigateTo({
      url: '/pageOrder/order/index',
    })
  },
  goServiceOrders() {
    wx.navigateTo({
      url: '/pageOrder/order/serviceOrders/index',
    })
  },
  goextendedfamily() {
    wx.navigateTo({
      url: '/pages/basicInformation/basicInformation',
    })
  },
  openApplet() {
    // const openid = GETSTORAGE('openid')
    // pushMessage({
    //   openId: openid
    // }).then(res => {
    //   console.log(res);
    // })
    wx.navigateToMiniProgram({
      appId: 'wxe1a65c353a9601f4',
      envVersion: 'trial',
      extraData: {
        index: 'shuju'
      }
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log(options);
    this.getUserInfo()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.getUserInfo()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})